]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
st-icon: Add resource-scale support
authorJonas Ådahl <jadahl@gmail.com>
Thu, 11 May 2017 04:35:09 +0000 (06:35 +0200)
committerJonas Ådahl <jadahl@gmail.com>
Fri, 1 Mar 2019 17:12:52 +0000 (17:12 +0000)
This commit adds support for scaling the StIcon resource (the icon
texture) according to the resource scale.

https://bugzilla.gnome.org/show_bug.cgi?id=765011

src/st/st-icon.c

index 9242d6b4e9ef66524d1ca412d0cf5b7969c4e964..04d2d1d3cc1208028c14ea7c8513482272bf4f46 100644 (file)
@@ -210,6 +210,12 @@ st_icon_style_changed (StWidget *widget)
   st_icon_update (self);
 }
 
+static void
+st_icon_resource_scale_changed (StWidget *widget)
+{
+  st_icon_update (ST_ICON (widget));
+}
+
 static void
 st_icon_class_init (StIconClass *klass)
 {
@@ -226,6 +232,7 @@ st_icon_class_init (StIconClass *klass)
   actor_class->paint = st_icon_paint;
 
   widget_class->style_changed = st_icon_style_changed;
+  widget_class->resource_scale_changed = st_icon_resource_scale_changed;
 
   pspec = g_param_spec_object ("gicon",
                                "GIcon",
@@ -344,6 +351,8 @@ st_icon_finish_update (StIcon *icon)
       g_signal_connect_object (priv->icon_texture, "notify::content",
                                G_CALLBACK (on_content_changed), icon, 0);
     }
+
+  clutter_actor_queue_relayout (CLUTTER_ACTOR (icon));
 }
 
 static void
@@ -366,9 +375,10 @@ st_icon_update (StIcon *icon)
   StIconPrivate *priv = icon->priv;
   StThemeNode *theme_node;
   StTextureCache *cache;
-  gint scale;
+  gint paint_scale;
   ClutterActor *stage;
   StThemeContext *context;
+  float resource_scale;
 
   if (priv->pending_texture)
     {
@@ -378,13 +388,16 @@ st_icon_update (StIcon *icon)
       priv->opacity_handler_id = 0;
     }
 
+  if (!st_widget_get_resource_scale (ST_WIDGET (icon), &resource_scale))
+    return;
+
   theme_node = st_widget_peek_theme_node (ST_WIDGET (icon));
   if (theme_node == NULL)
     return;
 
   stage = clutter_actor_get_stage (CLUTTER_ACTOR (icon));
   context = st_theme_context_get_for_stage (CLUTTER_STAGE (stage));
-  g_object_get (context, "scale-factor", &scale, NULL);
+  g_object_get (context, "scale-factor", &paint_scale, NULL);
 
   cache = st_texture_cache_get_default ();
 
@@ -393,16 +406,16 @@ st_icon_update (StIcon *icon)
                                                          theme_node,
                                                          priv->gicon,
                                                          priv->icon_size,
-                                                         scale,
-                                                         1);
+                                                         paint_scale,
+                                                         resource_scale);
 
   if (priv->pending_texture == NULL && priv->fallback_gicon != NULL)
     priv->pending_texture = st_texture_cache_load_gicon (cache,
                                                          theme_node,
                                                          priv->fallback_gicon,
                                                          priv->icon_size,
-                                                         scale,
-                                                         1);
+                                                         paint_scale,
+                                                         resource_scale);
 
   if (priv->pending_texture)
     {